export type OHLC = {
  trade_date: string; // YYYYMMDD
  open: number;
  high: number;
  low: number;
  close: number;
  vol?: number;
};

export type SeriesRow = OHLC & {
  atr?: number | null;
  std?: number | null;
  rolling_high?: number | null;
  rolling_low?: number | null;
};

export type SymbolMeta = {
  ts_code: string;
  name?: string;
  start_date: string;
  end_date: string;
  atr_period: number;
  std_period: number;
  holding_days: number;
};

export type DataBundle = {
  ts_code: string;
  name?: string;
  meta: SymbolMeta;
  series: SeriesRow[];
  summary?: {
    last_atr?: number | null;
    last_std?: number | null;
    rolling_high_last?: number | null;
    rolling_low_last?: number | null;
    highest_over_period?: number | null;
    lowest_over_period?: number | null;
  };
};

export type ProviderDailyRow = OHLC & { [key: string]: any };

export type Provider = {
  fetchTickers(): Promise<{ ts_code: string; name?: string }[]>;
  fetchDaily(ts_code: string, start_date: string, end_date: string): Promise<ProviderDailyRow[]>;
  fetchAdjFactor(ts_code: string, start_date: string, end_date: string): Promise<Map<string, number>>;
};